package ar.edu.unq.leezsi.model;

import ar.edu.unq.leezsi.exception.CowebRuntimeException;
import ar.edu.unq.leezsi.html.ComponentAdaptor;

public class ResourceModel extends Model<String> {

	private final String defaultValue;

	public ResourceModel(String property) {
		this(property, property);
	}

	public ResourceModel(String property, String defaultValue) {
		super(property);
		this.defaultValue = defaultValue;
	}

	@SuppressWarnings("unchecked")
	@Override
	public String get(String property) {
		return new ComponentAdaptor(this.getComponent()).getProperty(property);
	}

	protected String getDefaultValue() {
		return this.defaultValue;
	}

	@Override
	public void set(String property, Object value) {
		CowebRuntimeException.raise(new UnsupportedOperationException(
				"RosourceModel can't do 'set'"));
	}

}
